package com.linsen.core.common.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

@Getter
@AllArgsConstructor
public enum UseStatusType {
    UNABLE(0, "停用"),
    NORMAL(1, "正常"),
    ;

    @JsonValue
    private final Integer value;
    private final String desc;

    private static final Map<Integer, UseStatusType> VALUES = new HashMap<>();

    static {
        for (final UseStatusType useStatusType : UseStatusType.values()) {
            UseStatusType.VALUES.put(useStatusType.getValue(), useStatusType);
        }
    }

    @JsonCreator
    public static UseStatusType getByValue(Integer value) {
        return UseStatusType.VALUES.get(value);
    }
}
